home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / office german / PROPLUS.WW / PROPLSWW.CAB / as90.xsl.5DF9D670_534C_4AB2_B0C6_FF0B0C448C29 < prev    next >
Extensible Markup Language  |  2006-10-26  |  18KB  |  423 lines

  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0" xmlns:mssqlcrt="urn:sql-microsoft-com:sqlcrt" xmlns:mssqldbg="urn:sql-microsoft-com:sqldbg">
  3.     <xsl:output method="xml" indent="yes"/>
  4.  
  5.     <!-- This ALWAYS GENERATED file contains the definitions for the cartridges
  6.                  Microsoft Cartridge Interfaces (Analysis Services 2005)
  7.                  (C) Copyright 1988 - 2003 By Microsoft Corporation.      -->
  8.  
  9.     <!-- Microsoft Analysis Server 90 (Yukon) pluggable cartridge         -->
  10.  
  11.     <!-- Area of STANDARD parametrizations: these are externally passed   -->
  12.     <xsl:param name="in_CanUseParams">no</xsl:param>
  13.     <xsl:param name="in_IdentStartQuotingCharacter">[</xsl:param>
  14.     <xsl:param name="in_IdentEndQuotingCharacter">]</xsl:param>
  15.     <xsl:param name="in_StringStartQuotingCharacter">'</xsl:param>
  16.     <xsl:param name="in_StringEndQuotingCharacter">'</xsl:param>
  17.  
  18.     <!-- Area of CORE parametrizations: These are externally checked      -->
  19.     <mssqlcrt:provider type="prefix">Analysis Server</mssqlcrt:provider>
  20.  
  21.     <mssqlcrt:capabilities>
  22.         <mssqlcrt:supports-table-alias/>
  23.         <mssqlcrt:supports-column-alias/>
  24.     </mssqlcrt:capabilities>
  25.  
  26.     <mssqlcrt:schema-classes>
  27.         <mssqlcrt:schema-class>
  28.             <mssqlcrt:managed-provider>System.Data.OleDb</mssqlcrt:managed-provider>
  29.             <mssqlcrt:type>Microsoft.DataWarehouse.Design.OleDbSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  30.             <mssqlcrt:query-designer>
  31.                 <mssqlcrt:type>Microsoft.DataWarehouse.Controls.OleDbQueryDesigner, Microsoft.DataWarehouse</mssqlcrt:type>
  32.             </mssqlcrt:query-designer>
  33.         </mssqlcrt:schema-class>
  34.         <mssqlcrt:schema-class>
  35.             <mssqlcrt:managed-provider>System.Data.Odbc</mssqlcrt:managed-provider>
  36.             <mssqlcrt:type>Microsoft.DataWarehouse.Design.OdbcSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  37.         </mssqlcrt:schema-class>
  38.     </mssqlcrt:schema-classes>
  39.  
  40.     <!-- Area of internal parametrizations                                -->
  41.     <!-- overrideOfUseParams:
  42.              yes      = use always parametric queries
  43.              no       = never use parametric queries
  44.              nosubsel = use as yes, but not on subselects
  45.              auto     = use the value of in_CanUseParams to determine     -->
  46.     <xsl:variable name="overrideOfUseParams">auto</xsl:variable>
  47.     <!-- shouldProduceDebug:
  48.              yes      = produce debug information
  49.              no       = do not produce debug information                  -->
  50.     <xsl:variable name="shouldProduceDebug">yes</xsl:variable>
  51.  
  52.     <!-- Area of global variables initializations                         -->
  53.     <xsl:variable name="UseParams">
  54.         <xsl:choose>
  55.             <xsl:when test="normalize-space($overrideOfUseParams) = 'yes' or (normalize-space($overrideOfUseParams) = 'auto' and normalize-space($in_CanUseParams)='yes')">yes</xsl:when>
  56.             <xsl:when test="normalize-space($overrideOfUseParams) = 'nosubsel'">nosubsel</xsl:when>
  57.             <xsl:otherwise>no</xsl:otherwise>
  58.         </xsl:choose>
  59.     </xsl:variable>
  60.     <xsl:variable name="ProduceDebug" select="$shouldProduceDebug"/>
  61.     <xsl:variable name="IdentifierStartQuotingCharacter" select="normalize-space($in_IdentStartQuotingCharacter)"/>
  62.     <xsl:variable name="IdentifierEndQuotingCharacter" select="normalize-space($in_IdentEndQuotingCharacter)"/>
  63.     <xsl:variable name="StringStartQuotingCharacter" select="normalize-space($in_StringStartQuotingCharacter)"/>
  64.     <xsl:variable name="StringEndQuotingCharacter" select="normalize-space($in_StringEndQuotingCharacter)"/>
  65.  
  66.     <!-- Generated statement packaging                                    -->
  67.     <xsl:template match="/">
  68.         <xsl:element name="Statement">
  69.  
  70.             <!-- Generate query                                           -->
  71.             <xsl:element name="Text">
  72.                 <xsl:apply-templates select="./Statement/*[1]"/>
  73.             </xsl:element>
  74.  
  75.             <!-- Generate parameters                                      -->
  76.             <xsl:if test="count(./Statement/Parameters/Parameter)!=0 and ((normalize-space($UseParams)='yes') or (normalize-space($UseParams)='nosubsel'))">
  77.                 <xsl:element name="Parameters">
  78.                     <xsl:choose>
  79.                         <xsl:when test="/Statement/*[1]//Parameter/@ParamName">
  80.                             <xsl:for-each select="./Statement/Parameters/Parameter">
  81.                                 <xsl:element name="Parameter">
  82.                                     <xsl:attribute name="ref">
  83.                                         <xsl:value-of select="./@id"/>
  84.                                     </xsl:attribute>
  85.                                 </xsl:element>
  86.                             </xsl:for-each>
  87.                         </xsl:when>
  88.                         <xsl:otherwise>
  89.                             <xsl:for-each select="./Statement/*[1]//Parameter">
  90.                                 <xsl:element name="Parameter">
  91.                                     <xsl:attribute name="ref">
  92.                                         <xsl:value-of select="./@ref"/>
  93.                                     </xsl:attribute>
  94.                                 </xsl:element>
  95.                             </xsl:for-each>
  96.                         </xsl:otherwise>
  97.                     </xsl:choose>
  98.                 </xsl:element>
  99.             </xsl:if>
  100.  
  101.             <!-- Generate debug info                                      -->
  102.             <xsl:if test="$ProduceDebug='yes'">
  103.                 <xsl:element name="mssqldbg:DebugInfo">
  104.                     <xsl:element name="mssqldbg:GenerateParametricInfo">
  105.                         <xsl:attribute name="mssqldbg:Value">
  106.                             <xsl:value-of select="$UseParams"/>
  107.                         </xsl:attribute>
  108.                         <xsl:element name="mssqldbg:External">
  109.                             <xsl:value-of select="$in_CanUseParams"/>
  110.                         </xsl:element>
  111.                         <xsl:element name="mssqldbg:Internal">
  112.                             <xsl:value-of select="$overrideOfUseParams"/>
  113.                         </xsl:element>
  114.                     </xsl:element>
  115.                 </xsl:element>
  116.             </xsl:if>
  117.  
  118.         </xsl:element>
  119.     </xsl:template>
  120.  
  121.     <!-- Select statement                                                 -->
  122.     <xsl:template match="Select">
  123.         SELECT <xsl:apply-templates select="./Distinct"/>
  124.             <xsl:apply-templates select="./ColumnExpressions"/>
  125.             <xsl:apply-templates select="./Sources"/>
  126.             <xsl:apply-templates select="./Where"/>
  127.             <xsl:apply-templates select="./GroupBy"/>
  128.             <xsl:apply-templates select="./OrderBy"/>
  129.     </xsl:template>
  130.  
  131.     <xsl:template match="Distinct">
  132.         DISTINCT
  133.     </xsl:template>
  134.  
  135.     <xsl:template match="As">
  136.         <xsl:apply-templates select="./*[1]"/> AS <xsl:apply-templates select="./*[2]"/>
  137.     </xsl:template>
  138.  
  139.     <xsl:template match="NaturalJoin">
  140.         <xsl:for-each select="./*">
  141.             <xsl:apply-templates select="."/>
  142.             <xsl:if test="position()!=last()">
  143.                 NATURAL JOIN
  144.             </xsl:if>
  145.         </xsl:for-each>
  146.     </xsl:template>
  147.  
  148.     <xsl:template match="Sources">
  149.         <xsl:choose>
  150.             <xsl:when test="./NaturalJoin">
  151.             FROM <xsl:apply-templates select="./*[1]"/>
  152.             </xsl:when>
  153.             <xsl:otherwise>
  154.             FROM <xsl:call-template name="print-children-list"/>
  155.             </xsl:otherwise>
  156.         </xsl:choose>
  157.     </xsl:template>
  158.  
  159.     <xsl:template match="GroupBy">
  160.         GROUP BY <xsl:call-template name="print-children-list"/>
  161.     </xsl:template>
  162.  
  163.     <xsl:template match="OrderBy">
  164.         ORDER BY <xsl:call-template name="print-children-list"/>
  165.     </xsl:template>
  166.  
  167.     <xsl:template match="Where">
  168.         WHERE <xsl:apply-templates select="./*"/>
  169.     </xsl:template>
  170.  
  171.     <xsl:template match="ColumnExpressions">
  172.         <xsl:call-template name="print-children-list"/>
  173.     </xsl:template>
  174.  
  175.     <xsl:template match="SQLColumn">
  176.         <xsl:variable name="table">
  177.             <xsl:if test="name(..)!='Count' or name(./Column/*[1]) != 'Asterisk'"><xsl:apply-templates select="./Table"/></xsl:if>
  178.         </xsl:variable>
  179.         <xsl:variable name="column">
  180.             <xsl:apply-templates select="./Column"/>
  181.         </xsl:variable>
  182.         <xsl:choose>
  183.             <xsl:when test="$table = ''">
  184.                 <xsl:value-of select="$column"/>
  185.             </xsl:when>
  186.             <xsl:otherwise>
  187.                 <xsl:value-of select="concat($table,'.', $column)"/>
  188.             </xsl:otherwise>
  189.         </xsl:choose>
  190.     </xsl:template>
  191.  
  192.     <xsl:template match="Table">
  193.         <xsl:call-template name="build-quoted-schema-object"/>
  194.     </xsl:template>
  195.  
  196.     <xsl:template match="Column">
  197.         <xsl:apply-templates select="./Asterisk"/>
  198.         <xsl:apply-templates select="./Name"/>
  199.     </xsl:template>
  200.  
  201.     <xsl:template match="Table/Name|View/Name|Index/Name|Column/Name|Database/Name|Schema">
  202.         <xsl:call-template name="quote-identifier"/>
  203.     </xsl:template>
  204.  
  205.     <xsl:template match="OpaqueExpression">
  206.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  207.             (
  208.         </xsl:if>
  209.         <xsl:value-of select="."/>
  210.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  211.             )
  212.         </xsl:if>
  213.     </xsl:template>
  214.  
  215.     <xsl:template match="OrderExpression">
  216.         <xsl:apply-templates select="./*[1]"/>
  217.         <xsl:apply-templates select="./Asc"/>
  218.         <xsl:apply-templates select="./Desc"/>
  219.     </xsl:template>
  220.  
  221.     <xsl:template match="Asc">
  222.         ASC
  223.     </xsl:template>
  224.  
  225.     <xsl:template match="Desc">
  226.         DESC
  227.     </xsl:template>
  228.  
  229.     <!-- Asterisk                                                         -->
  230.     <xsl:template match="Asterisk">*</xsl:template>
  231.  
  232.     <!-- Count/Min/Max/Sum/Aggregate                                         -->
  233.     <xsl:template match="Count|Min|Max|Sum|Aggregate">
  234.         <xsl:variable name="function">
  235.             <xsl:choose>
  236.                 <xsl:when test="name()='Count'"> COUNT </xsl:when>
  237.                 <xsl:when test="name()='Min'"> MIN </xsl:when>
  238.                 <xsl:when test="name()='Max'"> MAX </xsl:when>
  239.                 <xsl:when test="name()='Sum'"> SUM </xsl:when>
  240.                 <xsl:when test="name()='Aggregate'"> AGGREGATE </xsl:when>
  241.             </xsl:choose>
  242.         </xsl:variable>
  243.         <xsl:value-of select="$function"/>( <xsl:apply-templates select="./*[1]"/> )
  244.     </xsl:template>
  245.  
  246.     <!-- Name/Key                                                          -->
  247.     <xsl:template match="Name|Key|DataId|CalculatedMeasure|UnaryOperator|CustomRollup|CustomRollupProperties|SkippedLevels|MemberValue">
  248.         <xsl:variable name="function">
  249.             <xsl:choose>
  250.                 <xsl:when test="name()='Name'"> NAME </xsl:when>
  251.                 <xsl:when test="name()='Key'"> KEY </xsl:when>
  252.                 <xsl:when test="name()='DataId'"> DATAID </xsl:when>
  253.                 <xsl:when test="name()='CalculatedMeasure'"> CalculatedMeasure </xsl:when>
  254.                 <xsl:when test="name()='UnaryOperator'"> UnaryOperator </xsl:when>
  255.                 <xsl:when test="name()='CustomRollup'"> CustomRollup </xsl:when>
  256.                 <xsl:when test="name()='CustomRollupProperties'"> CustomRollupProperties </xsl:when>
  257.                 <xsl:when test="name()='SkippedLevels'"> SkippedLevels </xsl:when>
  258.                 <xsl:when test="name()='MemberValue'"> MemberValue </xsl:when>
  259.             </xsl:choose>
  260.         </xsl:variable>
  261.         <xsl:value-of select="$function"/>( <xsl:call-template name="print-children-list"/> )
  262.     </xsl:template>
  263.  
  264.     <!-- Binary expressions                                               -->
  265.     <!-- Equal/NotEqual/Greater/GreaterOrEqual/Less/LessOrEqual/In/And/Or/Plus/Minus/Divide/Multiply
  266.          expressions                                                      -->
  267.     <xsl:template match="Equal|NotEqual|Greater|GreaterOrEqual|Less|LessOrEqual|In|And|Or|Plus|Minus|Divide|Multiply">
  268.         <xsl:variable name="operator">
  269.             <xsl:choose>
  270.                 <xsl:when test="name()='Equal'">            =        </xsl:when>
  271.                 <xsl:when test="name()='NotEqual'">            <>    </xsl:when>
  272.                 <xsl:when test="name()='Greater'">            >        </xsl:when>
  273.                 <xsl:when test="name()='GreaterOrEqual'">    >=        </xsl:when>
  274.                 <xsl:when test="name()='Less'">                <    </xsl:when>
  275.                 <xsl:when test="name()='LessOrEqual'">        <=    </xsl:when>
  276.                 <xsl:when test="name()='In'">                IN        </xsl:when>
  277.                 <xsl:when test="name()='And'">                AND        </xsl:when>
  278.                 <xsl:when test="name()='Or'">                OR        </xsl:when>
  279.                 <xsl:when test="name()='Plus'">                +        </xsl:when>
  280.                 <xsl:when test="name()='Minus'">            -        </xsl:when>
  281.                 <xsl:when test="name()='Divide'">            /        </xsl:when>
  282.                 <xsl:when test="name()='Multiply'">            *        </xsl:when>
  283.             </xsl:choose>
  284.         </xsl:variable>
  285.         (
  286.             <xsl:call-template name="print-children-list">
  287.                 <xsl:with-param name="operator" select="$operator"/>
  288.             </xsl:call-template>
  289.         )
  290.     </xsl:template>
  291.     
  292.     <!-- By default don't do anything                                     -->
  293.     <xsl:template match="*">
  294.     </xsl:template>
  295.  
  296.     <!-- Print a schema object                                               -->
  297.     <xsl:template name="build-quoted-schema-object"> 
  298.         <xsl:param name="schema-object-node" select="."/>
  299.  
  300.         <xsl:variable name="schema">
  301.             <xsl:apply-templates select="$schema-object-node/Schema"/>
  302.         </xsl:variable>
  303.         <xsl:variable name="table">
  304.             <xsl:apply-templates select="$schema-object-node/Name"/>
  305.         </xsl:variable>
  306.         <xsl:choose>
  307.             <xsl:when test="$schema = ''">
  308.                 <xsl:value-of select="$table"/>
  309.             </xsl:when>
  310.             <xsl:otherwise>
  311.                 <xsl:value-of select="concat($schema,'.', $table)"/>
  312.             </xsl:otherwise>
  313.         </xsl:choose>
  314.     </xsl:template>
  315.  
  316.     <!-- Convert an identifier to the OLEDB quotation form                -->
  317.     <xsl:template name="quote-identifier"> 
  318.         <xsl:param name="identifier" select="."/>
  319.  
  320.         <xsl:value-of select="$IdentifierStartQuotingCharacter"/>
  321.         <xsl:call-template name="normalize-entity-aux">
  322.             <xsl:with-param name="entity" select="$identifier"/>
  323.             <xsl:with-param name="end-quoting-char" select="$IdentifierEndQuotingCharacter"/>
  324.         </xsl:call-template>
  325.         <xsl:value-of select="$IdentifierEndQuotingCharacter"/>
  326.     </xsl:template>
  327.  
  328.     <!-- Convert a string to the string quotation form                    -->
  329.     <xsl:template name="quote-string"> 
  330.         <xsl:param name="string" select="."/>
  331.  
  332.         <xsl:value-of select="$StringStartQuotingCharacter"/>
  333.         <xsl:call-template name="normalize-entity-aux">
  334.             <xsl:with-param name="entity" select="$string"/>
  335.             <xsl:with-param name="end-quoting-char" select="$StringEndQuotingCharacter"/>
  336.         </xsl:call-template>
  337.         <xsl:value-of select="$StringEndQuotingCharacter"/>
  338.     </xsl:template>
  339.  
  340.     <!-- Convert an entity to the quotation form (recursive, aux)  by
  341.          duplicating the end quoting character                            -->
  342.     <xsl:template name="normalize-entity-aux"> 
  343.         <xsl:param name="entity"/>
  344.         <xsl:param name="end-quoting-char"/>
  345.  
  346.         <xsl:choose>
  347.             <xsl:when test="contains($entity, $end-quoting-char)">
  348.                 <xsl:value-of select="substring-before($entity, $end-quoting-char)"/>
  349.                 <xsl:value-of select="$end-quoting-char"/>
  350.                 <xsl:value-of select="$end-quoting-char"/>
  351.                 <xsl:call-template name="normalize-entity-aux">
  352.                     <xsl:with-param name="entity" select="substring-after($entity, $end-quoting-char)"/>
  353.                     <xsl:with-param name="end-quoting-char" select="$end-quoting-char"/>
  354.                 </xsl:call-template>
  355.             </xsl:when>
  356.             <xsl:otherwise>
  357.                 <xsl:value-of select="$entity"/>
  358.             </xsl:otherwise>
  359.         </xsl:choose>
  360.     </xsl:template>
  361.  
  362.     <!-- Print the children list                                          -->
  363.     <xsl:template name="print-children-list">
  364.         <xsl:param name="operator" select="','"/>
  365.         
  366.         <xsl:call-template name="print-list">
  367.             <xsl:with-param name="value-node" select="./*"/>
  368.             <xsl:with-param name="operator" select="$operator"/>
  369.         </xsl:call-template>
  370.     </xsl:template>
  371.  
  372.     <!-- Print a list                                                     -->
  373.     <xsl:template name="print-list">
  374.         <xsl:param name="operator" select="','"/>
  375.         <xsl:param name="value-node" select="."/>
  376.  
  377.         <xsl:for-each select="$value-node">
  378.             <xsl:apply-templates select="."/>
  379.             <xsl:if test="position()!=last()">
  380.                 <xsl:value-of select="$operator"/>
  381.             </xsl:if>
  382.         </xsl:for-each>
  383.     </xsl:template>
  384.  
  385.     <!-- Get the value of a parameter ref for the query                   -->
  386.     <xsl:template name="print-non-parametric-parameter-ref">
  387.         <xsl:param name="parameter-reference"/>
  388.  
  389.         <xsl:variable name="reference"><xsl:value-of select="$parameter-reference/@ref"/></xsl:variable>
  390.         <xsl:call-template name="print-non-parametric-parameter">
  391.             <xsl:with-param name="parameter" select="/Statement/Parameters/Parameter[@id=$reference]"/>
  392.         </xsl:call-template>
  393.     </xsl:template>
  394.  
  395.     <!-- Get the value of a parameter ref for the query                   -->
  396.     <xsl:template name="print-non-parametric-parameter">
  397.         <xsl:param name="parameter"/>
  398.  
  399.         <xsl:variable name="db-type"><xsl:value-of select="$parameter/@DBTYPE"/></xsl:variable>
  400.         <xsl:variable name="value"><xsl:value-of select="$parameter/text()"/></xsl:variable>
  401.         <xsl:choose>
  402.             <xsl:when test="$db-type = 'DBTYPE_BSTR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  403.             <xsl:when test="$db-type = 'DBTYPE_WSTR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  404.             <xsl:when test="$db-type = 'DBTYPE_STR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  405.             <xsl:when test="$db-type = 'DBTYPE_BOOL'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS bit)</xsl:when>
  406.             <xsl:when test="$db-type = 'DBTYPE_I1'"><xsl:value-of select="$value"/></xsl:when>
  407.             <xsl:when test="$db-type = 'DBTYPE_I2'"><xsl:value-of select="$value"/></xsl:when>
  408.             <xsl:when test="$db-type = 'DBTYPE_I4'"><xsl:value-of select="$value"/></xsl:when>
  409.             <xsl:when test="$db-type = 'DBTYPE_I8'"><xsl:value-of select="$value"/></xsl:when>
  410.             <xsl:when test="$db-type = 'DBTYPE_UI1'"><xsl:value-of select="$value"/></xsl:when>
  411.             <xsl:when test="$db-type = 'DBTYPE_UI2'"><xsl:value-of select="$value"/></xsl:when>
  412.             <xsl:when test="$db-type = 'DBTYPE_UI4'"><xsl:value-of select="$value"/></xsl:when>
  413.             <xsl:when test="$db-type = 'DBTYPE_UI8'"><xsl:value-of select="$value"/></xsl:when>
  414.             <xsl:when test="$db-type = 'DBTYPE_R4'"><xsl:value-of select="$value"/></xsl:when>
  415.             <xsl:when test="$db-type = 'DBTYPE_R8'"><xsl:value-of select="$value"/></xsl:when>
  416.             <xsl:when test="$db-type = 'DBTYPE_DATE'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS datetime)</xsl:when>
  417.             <xsl:when test="$db-type = 'DBTYPE_DBTIMESTAMP'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS datetime)</xsl:when>
  418.             <xsl:when test="$db-type = 'DBTYPE_CY'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS money)</xsl:when>
  419.             <xsl:when test="$db-type = 'DBTYPE_VARIANT'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  420.         </xsl:choose>
  421.     </xsl:template>
  422. </xsl:stylesheet>
  423.